package com.tyron;

import com.tyron.spi.InternetService;

import java.util.ServiceLoader;

/**
 * @description: serviceLoader加载
 * @author: tyron
 * @time: 2024/8/7
 */
public class Application {
    public static void main(String[] args) {
        // 使用ServiceLoader加载，默认会加载META-INF/services/com.tyron.spi.InternetService
        ServiceLoader<InternetService> serviceLoader = ServiceLoader.load(InternetService.class);
        // 遍历serviceLoader
        for (InternetService internetService : serviceLoader) {
            internetService.connectInternet();
        }
    }
}